From 1bb1f723dab2fc8b88b7f7273d0a7fa11134b936 Mon Sep 17 00:00:00 2001 From: Justin Burkett Date: Wed, 8 Dec 2021 23:57:20 -0500 Subject: [PATCH] Fix key-chord handling It turns out we don't need to do anything too tricky for key-chords, because this-single-command-raw-keys returns the correct key-sequence Fixes #254 --- which-key.el | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/which-key.el b/which-key.el index 0fa2fa39ad7..edbad7a3687 100644 --- a/which-key.el +++ b/which-key.el @@ -2588,22 +2588,11 @@ Finally, show the buffer." (defun which-key--this-command-keys () "Version of `this-single-command-keys' corrected for key-chords and god-mode." (let ((this-command-keys (this-single-command-keys))) - (when (and (equal this-command-keys [key-chord]) + (when (and (vectorp this-command-keys) + (> (length this-command-keys) 0) + (eq (aref this-command-keys 0) 'key-chord) (bound-and-true-p key-chord-mode)) - (setq this-command-keys - (condition-case nil - (let ((rkeys (recent-keys))) - (vector 'key-chord - ;; Take the two preceding the last one, because the - ;; read-event call in key-chord seems to add a - ;; spurious key press to this list. Note this is - ;; different from guide-key's method which didn't work - ;; for me. - (aref rkeys (- (length rkeys) 3)) - (aref rkeys (- (length rkeys) 2)))) - (error (progn - (message "which-key error in key-chord handling") - [key-chord]))))) + (setq this-command-keys (this-single-command-raw-keys))) (when (and which-key--god-mode-support-enabled (bound-and-true-p god-local-mode) (eq this-command 'god-mode-self-insert)) -- 2.30.2